<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="Annotation.DataBase.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.net.*" %>

<%--2013.05.29 testing success--%>

<%
String tea_school = new String(request.getParameter("selectSchool").getBytes("ISO-8859-1"),"UTF-8");
String tea_name = request.getParameter("teachername");
String tea_num = request.getParameter("teachernumber");
String pwd = request.getParameter("pwd");
String gender = request.getParameter("gender");

//out.println("HI~"+tea_school);

%>
<%
//String schoolname = request.getParameter("schoolname");//input text
//boolean adding=true;

MySQLCommand ss= new MySQLCommand();
String sql="select PK_school from school Where school='"+tea_school+"'";
ResultSet rs = ss.selectSQL(sql);
int Sch=-1;
while(rs.next()){
	//System.out.println(rs.getInt("PK_school"));
	Sch=rs.getInt("PK_school");
}
if(Sch != -1){
	sql="insert into teacher_info (teacher_number,teacher_name,teacher_password,teacher_gender,PK_school) values ('"+tea_num+"','"+tea_name+"','"+pwd+"','"+gender+"',"+Sch+")";

	ss.executeSQL(sql);
	//out.print("<script>alert('adding teacher account is succeful!');</script>");
	//out.print(sql);	
}
ss.closeDB();
%>

<% 
String url = "createTeacherAccSignal.jsp";
//out.println(url);
response.sendRedirect(url);
%>


